import { defineStore } from 'pinia'
import { ref, computed } from 'vue'

export const useCounterStore = defineStore('counter', () => {
  // 定义 state
  const count = ref(0)

  // 定义 getters
  const double = computed(() => count.value * 2)

  // 定义 actions
  const increment = () => {
    count.value++
  }

  const decrement = () => {
    count.value--
  }

  const nun1 = ref(100)
  // 千万不要忘记这里要 return
  return { count, double,nun1, increment, decrement }
},{
  unistorage: {
    key:'cp-counter',
    paths:['count','nun1']
  }
})